package com.quanyan.orderpay.web.admin;

import com.quanyan.api.APIResponse;
import com.quanyan.assets.response.RespBankInfo;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.common.constants.Constants;
import com.quanyan.common.utils.MD5Utils;
import com.quanyan.orderpay.request.ReqBatchWithdrawQuery;
import com.quanyan.orderpay.request.ReqWithdrawApplyList;
import com.quanyan.orderpay.request.ReqWithdrawFormData;
import com.quanyan.orderpay.request.WithdrawPayInfo;
import com.quanyan.orderpay.response.RespBatchWithdraw;
import com.quanyan.orderpay.response.RespWithdrawApply;
import com.quanyan.orderpay.service.OrderPayService;
import com.quanyan.orderpay.service.OrderProcessService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.List;

/**
 * Created by zhuo.shi on 2016/8/17.
 */
@RestController
@RequestMapping("/admin/api/orderypay/withdraw")
public class WithdrawController {

    @Autowired
    private OrderPayService orderPayService;

    @Autowired
    private OrderProcessService orderProcessService;

    @RequestMapping(value = "/applyList")
    public APIResponse listWithdrawApply(@RequestBody ReqWithdrawApplyList reqWithdrawApplyList){
        return orderPayService.queryApplyWidthdrawList(reqWithdrawApplyList);
    }

    @RequestMapping(value = "/batchTrans", method = RequestMethod.POST)
    public APIResponse batchTrans(@RequestBody ReqWithdrawFormData reqWithdrawFormData, HttpServletRequest request){
     //   return orderPayService.getBatchTransferFundByAlipayHtmlForm(reqWithdrawFormData);//调用支付系统
        return orderPayService.batchTrans(reqWithdrawFormData);//调用支付系统
    }

    //批次查询
    @RequestMapping(value = "/batchWithdrawQuery", method = RequestMethod.POST)
    public APIResponse<PageObj<List<RespBatchWithdraw>>> batchWithdrawQuery(@RequestBody ReqBatchWithdrawQuery reqBatchWithdrawQuery) throws ParseException {
        return orderProcessService.batchWithdrawQuery(reqBatchWithdrawQuery);
    }

    //获取明细
    @RequestMapping(value = "/getApplyByBatchNo", method = RequestMethod.GET)
    public APIResponse<List<RespWithdrawApply>> getApplyByBatchNo(String batchNo){
        return orderProcessService.getApplyByBatchNo(batchNo);
    }


    //获取银行列表
    @RequestMapping(value = "/getBankList", method = RequestMethod.GET)
    public APIResponse<List<RespBankInfo>> getBankList(){
        return orderPayService.getBankList();
    }
//    @RequestMapping(value = "/payByAlipay", method = RequestMethod.POST)
//    public APIResponse payByAlipay(@RequestBody ReqWithdrawFormData reqWithdrawFormData, HttpServletRequest request){
//        return orderPayService.getBatchTransferFundByAlipayHtmlForm(reqWithdrawFormData);//调用支付系统
//    }
//
//    @RequestMapping(value = "/payByWeichat", method = RequestMethod.POST)
//    public APIResponse payByWeichat(@RequestBody WithdrawPayInfo payInfo){
//        return orderPayService.transferFundByWechat(payInfo);
//    }

}
